package com.ayitubie.refuelweb.config.quartz;

import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class OilPriceQuartzConfig {

    @Bean
    public JobDetail oilPriceJobDetail() {
        return JobBuilder.newJob(OilPriceQuartz.class).withIdentity("oilPriceQuartz").storeDurably().build();
    }

    @Bean
    public Trigger oilPriceTrigger() {
        CronScheduleBuilder scheduleBuilder
                = CronScheduleBuilder.cronSchedule("0 */10 */1 * * ? *");
        return TriggerBuilder
                .newTrigger()
                .forJob(oilPriceJobDetail())
                .withIdentity("oilPriceQuartz")
                .withSchedule(scheduleBuilder).build();
    }
}
